package com.example.tests;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import org.testng.annotations.Test;

import com.example.fw.Groups;

public class GroupCreationTests extends TestBase {
	
	@Test (dataProvider = "randomGroups", dataProviderClass = GroupDataGenerator.class)
	public void testValidGroupCanBeCreated(GroupObject validGroup) throws Exception {
		Groups oldList = app.getGroupHelper().getGroups();
		//action
		app.getGroupHelper().createGroup(validGroup);
		//verification
		Groups newList = app.getGroupHelper().getGroups();
		assertThat(newList, equalTo(oldList.withAdded(validGroup)));
	}

	@Test
	public void testGroupWithEmptyCanBeCreated() throws Exception {
		GroupObject emptyDataGroup = new GroupObject()
			.setName("")
			.setHeader("")
			.setFooter("");
		Groups oldList = app.getGroupHelper().getGroups();
		//action
		app.getGroupHelper().createGroup(emptyDataGroup);
		//verification
		Groups newList = app.getGroupHelper().getGroups();
		assertThat(newList, equalTo(oldList.withAdded(emptyDataGroup)));
	}
	
}
